home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / program / vdit.arc / vdi.c < prev    next >
C/C++ Source or Header  |  1988-07-12  |  4KB  |  206 lines

  1. /*
  2.  * PD mini VDI interface, Eric Gisin
  3.  */
  4.  
  5. #include <osbind.h>
  6. #include <vdi.h>
  7. #include <gfont.h>
  8.  
  9. #define    NULL    0L
  10.  
  11. static    short ct [12];        /* VDI/AES control block */
  12. static    short ii [140];
  13. static    short pi [16];
  14. static    short io [47];
  15. static    short po [16];
  16. struct Params v_ps = {ct, ii, pi, io, po, NULL};
  17. struct Params v_pt = {ct, ii, pi, io, po, NULL}; /* modifiable version of v_ps */
  18.  
  19. /* VDI operations with no parameters */
  20. vdi_none(h, op)
  21.     short h, op;
  22. {
  23.     vdi_setup(op, h, 0, 0);
  24.     vdi(&v_ps);
  25. }
  26.  
  27. /* VDI operations with one integer parameter */
  28. vdi_int1(h, op, i)
  29.     short h, op;
  30.     short i;
  31. {
  32.     ii[0] = i;
  33.     vdi_setup(op, h, 1, 0);
  34.     vdi(&v_ps);
  35.     return io[0];
  36. }
  37.  
  38. /* VDI operations with one point parameter */
  39. vdi_pnt1(h, op, x, y)
  40.     short h, op;
  41.     short x, y;
  42. {
  43.     pi[0] = x, pi[1] = y;
  44.     vdi_setup(op, h, 0, 1);
  45.     vdi(&v_ps);
  46. }
  47.  
  48. vdi_pnt4v(h, op, fn, pnt)
  49.     short h;
  50.     short op, fn;
  51.     short *pnt;
  52. {
  53.     register int i;
  54.  
  55.     for (i = 0; i < 4; i++)
  56.         pi[i] = pnt[i];
  57.     vdi_setup(op, h, 0, 2);
  58.     ct[5] = fn;
  59.     vdi(&v_ps);
  60. }
  61.  
  62. /* open virtual work */
  63. v_opnvwk(in, hp, out) /* todo: vdi_open */
  64.     short in[];
  65.     short *hp;
  66.     short out[];
  67. {
  68.     v_pt.ii = in;
  69.     v_pt.io = out;
  70.     v_pt.pi = pi;
  71.     v_pt.po = out+34;
  72.     vdi_setup(100, *hp, 11, 0);
  73.     vdi(&v_pt);
  74.     *hp = ct[6];
  75. }
  76.  
  77. vdi_cpyfm(h, op, mode, sdr, src, dst)
  78.     short h, op;
  79.     short mode;
  80.     short *sdr;            /* source/dest rectangles */
  81.     Form *src, *dst;        /* source/dest forms */
  82. {
  83.     register int i;
  84.  
  85.     *((Form**)&ct[7]) = src;
  86.     *((Form**)&ct[9]) = dst;
  87.     ii[0] = mode;
  88.     for (i = 0; i < 8; i++)
  89.         pi[i] = sdr[i];
  90. /***
  91.     *((Rect*)&pi[0]) = sdr[0];
  92.     *((Rect*)&pi[4]) = sdr[1];
  93. ***/
  94.     vdi_setup(op, h, 1, 4); vdi(&v_ps);
  95. }
  96.  
  97. vst_alignment(h, x, y, xp, yp) 
  98.     short h;
  99.     short x, y;
  100.     short *xp, *yp;
  101. {
  102.     ii[0] = x, ii[1] = y;
  103.     vdi_setup(39, h, 2, 0);
  104.     vdi(&v_ps);
  105.     *xp = io[0], *yp = io[1];
  106. }
  107.  
  108. v_gtext(h, x, y, s)
  109.     short h;
  110.     short x, y;
  111.     unsigned char *s;
  112. {
  113.     register int i;
  114.  
  115.     for (i = 0; *s != 0 && i < 140; i++)
  116.         ii[i] = *s++;
  117.     pi[0] = x; pi[1] = y;
  118.     vdi_setup(8, h, i, 1);
  119.     vdi(&v_ps);
  120. }
  121.  
  122. vqt_attributes(h, at)
  123.     short *at;    /*struct vdi_tattr *at;*/
  124. {
  125.     v_pt.io = at; v_pt.po = at+6;
  126.     vdi_setup(38, h, 0, 0);
  127.     vdi(&v_pt);
  128. }
  129.  
  130. static char *vdi_scratch = NULL;    /* VDI/LineA scratch buffer */
  131.  
  132. #if 0
  133. /* load GDOS fonts using user's vx_load_fonts */
  134. vst_load_fonts(h, select)
  135.     short h, select;
  136. {
  137.     GFont * fp;
  138.     extern char * malloc();
  139.     extern GFont * vx_load_fonts();    /* user routine to load fonts */
  140.  
  141.     if (vdi_scratch == NULL)
  142.         vdi_scratch = malloc(1024);    /* scratch buffer */
  143.     *((char **)&ct[7]) = vdi_scratch;
  144.     ct[9] = 256;            /* offset of enlargment buffer */
  145.     *((char **)&ct[10]) = fp = vx_load_fonts(select); /* GDOS font list */
  146.     if (fp == 0)
  147.         return 0;
  148.     vdi_setup(119, h, 0, 0);
  149.     vdi(&v_ps);
  150.     return io[0];            /* number of fonts loaded */
  151. }
  152.  
  153. vst_unload_fonts(h)
  154. {
  155.     extern void vx_unload_fonts();
  156.  
  157.     vdi_setup(120, h, 0, 0);
  158.     vdi(&v_ps);
  159.     vx_unload_fonts();
  160. }
  161. #endif
  162.  
  163. /* load GDOS fonts using fp */
  164. /* make sure your ct array is large enough if you port this */
  165. vstx_load_fonts(h, fp)
  166.     short h;
  167.     GFont *fp;
  168. {
  169.     extern char * malloc();
  170.  
  171.     if (vdi_scratch == NULL)
  172.         vdi_scratch = malloc(1024);    /* scratch buffer */
  173.     *((char **)&ct[7]) = vdi_scratch;
  174.     ct[9] = 256;            /* offset of enlargment buffer */
  175.     *((char **)&ct[10]) = fp;
  176.     if (fp == NULL)
  177.         return 0;
  178.     vdi_setup(119, h, 0, 0);
  179.     vdi(&v_ps);
  180.     return io[0];            /* number of fonts loaded */
  181. }
  182.  
  183. vstx_unload_fonts(h)
  184. {
  185.     vdi_setup(120, h, 0, 0);
  186.     vdi(&v_ps);
  187. }
  188.  
  189. #if 0
  190. /*
  191.  * This code invokes VDI ESC 102 code (page 440 in the July '86
  192.  * Abacus ST Internals BIOS listing).  I decompiled some library
  193.  * routines to see how to make it work.  It may not work on new ROMS.
  194.  * Martin Minow, Arlington MA 02174.  This routine is in the public domain.
  195.  */
  196. vt_set_font(fp)
  197.     register GFont * fp;
  198. {
  199.     (*(GFont**)&ii[0]) = fp;    /* Put font info in intin[0] */
  200.     vdi_setup(5, 0, 2, 0);
  201.     ct[5] = 102;
  202.     vdi(&v_ps);
  203. }
  204. #endif
  205.  
  206.